<template>
  <view class="box">
    <view class="yh_input">
      <view>
        <text v-if="required" style="color: red">*</text>
        <text>{{ label }}</text>
        <text v-if="requiredRight" style="color: red">*</text>
      </view>
      <view class="inputBox">
        <input
          class="input"
          :type="type"
          :maxlength="maxLength"
          :disabled="disabled"
          :placeholder="placeholder"
          :value="modelValue"
          @input="getInputValue($event.target.value)"
        />
        <nut-icon v-if="iconName" font-class-name="iconfont" class-prefix="iconfont" :name="iconName" :size="iconSize" :color="iconColor" style="margin-right: -10px;"/>
        <nut-icon v-if="image" font-class-name="iconfont" class-prefix="iconfont" name=".icon-jiantou" size="20" color="#cccccc" style="margin-right: -10px;"/>
        <nut-icon v-if="locationIconState" font-class-name="iconfont" class-prefix="iconfont" name=".icon-weizhi" size="16" color="#DC2734" class="locationIcon"/>
      </view>
    </view>
  </view>
</template>
<script lang='ts'>
export default {
  name: "yh_input",
  props: {
    modelValue: {
      default: "",
    },
    label: {
      default: "",
    },
    image: {
      default: false,
    },
    locationIconState: {
      default: false,
    },
    required: {
      default: false,
    },
    requiredRight: {
      default: false,
    },
    disabled: {
      default: false,
    },
    type: {
      default: "text",
    },
    maxLength: {
      default: 50,
    },
    placeholder: {
      default: "",
    },
    iconName:{
      default:'',
    },
    iconSize:{
      default:'',
    },
    iconColor:{
      default:'',
    }
  },
  setup(_props, { emit }) {
    console.log(_props)
    const getInputValue = (value) => {
      emit("update:modelValue", value);
    };
    return {
      getInputValue,
    };
  },
};
</script>
<style lang="scss">
.box {
  background: #ffffff;
  .yh_input {
    padding: 13px 0;
    margin-left: 16px;
    border-bottom: 1px solid #eeeeee;
    background: #ffffff;

    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    text {
      width: 120px;
      font-size: 13px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #666666;
      line-height: 13px;
      padding: 0 2px;
    }
    .inputBox {
      flex: 1;
      padding: 0 16px 0 0;
      display: flex;
      flex-direction: row;
      align-items: center;
      .input {
        flex: 1;
        text-align: right;
        font-size: 13px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #cccccc;
      }
      .locationIcon {
        width: 16px;
        height: 16px;
        margin-left: 13px;
        border-left: 1px solid #eeeeee;
        padding-left: 6px;
        margin-right: -10px;
      }
    }
  }
}
</style>
